<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>



<!DOCTYPE html>
<html>
<head id="Head1">
<title>操作</title>

	<script src="/resources/Scripts/jquery.min.js" type="text/javascript"></script>
	<script src="/resources/Scripts/JScriptIndex.js" type="text/javascript"></script>
	<script src="/resources/Res/easyui/jquery.easyui.min.js" type="text/javascript"></script>
	<script src="/resources/Res/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
	<link href="/resources/Res/easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
	<script src="/resources/Res/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<link href="/resources/Content/Default.css" rel="stylesheet" type="text/css" />
	<link href="/resources/Res/easyui/themes/icon.css" rel="stylesheet" type="text/css" />
	<link href="/resources/Content/IndexStyle.css" rel="stylesheet" type="text/css" />

<style type="text/css">
<!--
.easyui-dialog .input .editor-label-search {
	width: 60px;
}

.easyui-dialog .input .editor-field-search {
	width: 115px;
}

.easyui-dialog	.editor-field-to {
	width: 230px;
	text-align: left;
}
-->
</style>
</head>
<body class="easyui-layout">
	<div region="west" border="false"
		style="width: 400px; padding-top: 5px; padding-left: 5px;">
		<table id="flexigridData">
		</table>
	</div>
	<div region="center" border="false" fit="false"
		style="padding-top: 5px; padding-left: 5px; padding-right: 5px;">
		<table id="SetStudentflexigridData">
		</table>
	</div>

	<div id="divQuery" title="查询列表" class="easyui-dialog" closed="true"
		modal="false" iconcls="icon-search" style="width: 420px;">
		<div class="input">
			<div class="editor-label-search" style="width: 70px;">
				<label for="stuId">学员编号</label>
			</div>
			<div class="editor-field-search" style="width: 130px;">
				<input type='text' id='stuId' style="width: 100px" />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search" style="width: 70px;">
				<label for="stuName">姓名</label>
			</div>
			<div class="editor-field-search" style="width: 130px;">
				<input type='text' id='stuName' style="width: 100px" />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search" style="width: 70px;">
				<label for="stuCardId">身份证号</label>
			</div>
			<div class="editor-field-search" style="width: 130px;">
				<input type='text' id='stuCardId' style="width: 100px" />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search" style="width: 70px;">
				<label for="stuPhone">手机</label>
			</div>
			<div class="editor-field-search" style="width: 130px;">
				<input type='text' id='stuPhone' style="width: 100px" />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search" style="width: 70px;">
				<label for="stuClassType">班别</label>
			</div>
			<div class="editor-field-search" style="width: 300px;">
				<select id="stuClassType" name="stuClassType" style="width: 120px">
				
					<option value="">请选择</option>
					<option value="C1普通班">C1普通班</option>
					<option value="C2普通班">C2普通班</option>
					<option value="C1贵宾班">C1贵宾班</option>
					<option value="外校学员">外校学员</option>

				</select>
			</div>
		</div>
		<div class="editor-label-search" style="width: 70px">考试日期</div>
		<div class="editor-field-to" style="width: 300px">
			<input type="text" id="S_kaoshiStart_Time" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'S_kaoshiEnd_Time\');}'})" style="width: 130px" />
				 到 
		    <input type="text" id="S_kaoshiEnd_Time" onclick="WdatePicker({minDate:'#F{$dp.$D(\'S_kaoshiStart_Time\');}'})" style="width: 130px" />
		</div>	
		 <div class="input">
			<div class="editor-label-search" style="width: 70px;">
				<label for="exaSubject">考试科目</label>
			</div>
			<div class="editor-field-search" style="width: 150px;">
				<select id="exaSubject" name="exaSubject" style="width: 120px">
				
					<option value="">请选择</option>
					<option value="科目一理论">科目一理论</option>
					<option value="科目二">科目二</option>
					<option value="科目三">科目三</option>
					<option value="科目四理论">科目四理论</option>
				</select>
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search" style="width: 0px;">
				<label for="asExamResults"></label>
			</div>
			<div class="editor-field-search" style="width: 150px;">
				<select id="asExamResults" name="asExamResults" style="width: 120px">
				
					<option value="">请选择</option>
					<option value="合格">合格</option>
					<option value="不合格">不合格</option>
					
				</select>
			</div>
		</div>
		
	</div>

	<script type="text/javascript" language="javascript">
		$(function() {
			$('#flexigridData').datagrid({
				title : '待发送列表', //列表的标题
				iconCls : 'icon-site',
				width : 'auto',
				height : 'auto',
				nowrap : false,
				striped : true,
				collapsible : true,
				url : '/Message/getSendStus', //获取数据的url
				//queryParams: { search: '2&1^' },
				sortName : 'stuId',
				sortOrder : 'desc',
				idField : 'stuId',

				toolbar : [ {
					text : '查询',
					iconCls : 'icon-search',
					handler : function() {
						flexiQuery();
					}
				}, {
					text : '确认选择',
					iconCls : 'icon-ok',
					handler : function() {
						return flexiSelect();
					}
				}

				],
				columns : [ [

				{
					field : 'ck',
					checkbox : true
				},
				{
					field : 'stuId',
					title : '<label for="stuId">学员编号</label>',
					width : 60
				}, {
					field : 'stuName',
					title : '<label for="stuName">姓名</label>',
					width : 80
				}, {
					field : 'stuPhone',
					title : '<label for="stuPhone">手机</label>',
					width : 100
				}, {
					field : 'stuClassType',
					title : '<label for="stuClassType">班别</label>',
					width : 80
				} ] ],
				pagination : true,
				rownumbers : true

			});
		});

		//“查询”按钮，弹出查询框
		function flexiQuery() {
			$('#divQuery')
					.dialog(
							{
								buttons : [
										{
											text : '查询',
											iconCls : 'icon-ok',
											handler : function() {		
												$('#flexigridData').datagrid(
														'reload', {
															msgId : $("#msgId").val(),
															stuId : $("#stuId").val(),
															stuName : $("#stuName").val(),
															stuCardId : $("#stuCardId").val(),
															stuPhone : $("#stuPhone").val(),
															stuClassType : $("#stuClassType").val(),
															S_kaoshiStart_Time :$("#S_kaoshiStart_Time").val(),
															S_kaoshiEnd_Time : $("#S_kaoshiEnd_Time").val(),
															exaSubject : $("#exaSubject").val(),
															asExamResults : $("#asExamResults").val()
														});

											}
										}, {
											text : '取消',
											iconCls : 'icon-cancel',
											handler : function() {
												$('#divQuery').dialog("close");
											}
										} ]
							});
			$('#divQuery').dialog("open");
		};

		function xdive_arrays(aArr, bArr) { //第一個a數組減去第二個b數組,得到的数组是a数组消除ab数组的交集
			if (bArr.length == 0) {
				return aArr
			}
			var diff = [];
			var str = bArr.join("&quot;&quot;");
			for ( var e in aArr) {
				if (str.indexOf(aArr[e]) == -1) {
					diff.push(aArr[e]);
				}
			}
			return diff;
		}

		//“选择”按钮，在其他（与此页面有关联）的页面中，此页面以弹出框的形式出现，选择页面中的数据
		function flexiSelect() {

			var rows = $('#flexigridData').datagrid('getSelections');
			if (rows.length == 0) {
				$.messager.alert('操作提示', '请选择数据!', 'warning');
				return false;
			}

			var arr = [];
			for (var i = 0; i < rows.length; i++) {
				arr.push(rows[i].stuId);
			}
			//alert(search);
			//将待发送列表装载到确认发送列表
			//执行查询
			$('#SetStudentflexigridData').datagrid('reload', {
				stuIds : arr.join(","),
				ssid : '20180108160116705934302ed5e4ad5'
			});
		}
	</script>
	<script type="text/javascript" language="javascript">
		$(function() {

			$('#SetStudentflexigridData').datagrid({
				title : '确认发送列表', //列表的标题
				iconCls : 'icon-site',
				width : 'auto',
				height : 'auto',
				nowrap : false,
				striped : true,
				collapsible : true,
				url : '/Message/getSendList', //获取数据的url
				queryParams : {
				},
				sortName : 'stuId',
				sortOrder : 'desc',
				idField : 'stuId',

				toolbar : [

				{
					text : '取消发送',
					iconCls : 'icon-remove',
					handler : function() {
						return SelflexiDelete();
					}
				}, 	
				{
					text : '确认发送',
					iconCls : 'icon-ok',
					handler : function() {
						return SelBaokaoflexiSelect();
					}
				} ],
				columns : [ [

				{
					field : 'ck',
					checkbox : true
				}, {
					field : 'stuId',
					title : '<label for="stuId">学员编号</label>',
					width : 60
				}, {
					field : 'stuName',
					title : '<label for="stuName">姓名</label>',
					width : 80
				}, {
					field : 'stuPhone',
					title : '<label for="stuPhone">手机</label>',
					width : 100
				}, {
					field : 'stuClassType',
					title : '<label for="stuClassType">班别</label>',
					width : 80
				}, {
					field : 'msgCode',
					title : '短信编号',
					width : 50
				}, {
					field : 'msgContent',
					title : '短信内容',
					width : 180
				} ] ],
				pagination : false,
				rownumbers : true

			});

		});
		//“选择报考”按钮，在其他（与此页面有关联）的页面中，此页面以弹出框的形式出现，选择页面中的数据
		function SelBaokaoflexiSelect() {

			var rows = $('#SetStudentflexigridData').datagrid('getSelections');
			if (rows.length == 0) {
				$.messager.alert('操作提示', '请选择学员!', 'warning');
				return false;
			}

			var arr = [];
			var pkid = [];
			var names = [];
			var SsContent = "";
			for (var i = 0; i < rows.length; i++) {
				arr.push(rows[i].stuPhone);

				names.push(rows[i].stuName);
			}

			$.messager.confirm('操作提示', "确认要发送吗？", function(r) {
				if (r) {
					$.post("/Message/sendMsgToStu", {
						stuPhones : arr.join(","),
						msgCode : rows[0].msgCode,
						msgContent : rows[0].msgContent,
						stuNames : names.join(","),
						SSID : '20180108160116705934302ed5e4ad5'
					}, function(res) {
						//alert(res);
						$.messager.alert('操作提示', res, 'warning');
						//$("#flexigridData").datagrid("reload");
						$("#flexigridData").datagrid("clearSelections");
						//$("#SetStudentflexigridData").datagrid("reload");
						$("#SetStudentflexigridData").datagrid(
								"clearSelections");
					});
				}
			});
		}
		//“选择”按钮，在其他（与此页面有关联）的页面中，此页面以弹出框的形式出现，选择页面中的数据
		function SelflexiSelect() {

			var rows = $('#SetStudentflexigridData').datagrid('getSelections');
			if (rows.length == 0) {
				$.messager.alert('操作提示', '请选择数据!', 'warning');
				return false;
			}

			var arr = [];
			for (var i = 0; i < rows.length; i++) {
				arr.push(rows[i].stuId);
			}
			arr.push("^");
			for (var i = 0; i < rows.length; i++) {
				arr.push(rows[i].FK_TEID);
			}
			//主键列和显示列之间用 ^ 分割   每一项用 , 分割
			if (arr.length > 0) {//一条数据和多于一条
				returnParent(arr.join("&")); //每一项用 & 分割
			}
		}

		//删除的按钮
		function SelflexiDelete() {
			var rows = $('#SetStudentflexigridData').datagrid('getSelections');
			var arr = [];
			if (rows.length == 0) {
				$.messager.alert('操作提示', '请选择数据!', 'warning');
				return false;
			}
			$.messager.confirm('操作提示', "确认删除这 " + rows.length + " 项吗？",
					function(r) {

						for (var i = rows.length - 1; i >= 0; i--) {
							var index = $('#SetStudentflexigridData').datagrid(
									'getRowIndex', rows[i]); //获取某行的行号
							$('#SetStudentflexigridData').datagrid('deleteRow',
									index); //通过行号移除该行
						}

					});

		}
	</script>
</body>

</html>
